export const actions = {
    getNameList({}) {
        return this.$api.talk.getNameList().then((res) => {
            if(res.data.status=="OK"){
                return Promise.resolve(res.data.data)
            }
            else{
                return Promise.reject(new Error(res.data.msg))
            }
        },(error) => {
            return Promise.reject(error)
        }).catch((error)=>{
            return Promise.reject(error)
        })
    },
    getTalkList({},username) {
        return this.$api.talk.getTalkList(username).then((res) => {
            if(res.data.status=="OK"){
                return Promise.resolve(res.data.data)
            }
            else{
                return Promise.reject(new Error(res.data.msg))
            }
        },(error) => {
            return Promise.reject(error)
        }).catch((error)=>{
            return Promise.reject(error)
        })
    },
    insertSentence({},{username,admin,content}){
        return this.$api.talk.insertSentence(username,admin,content).then((res) => {
            if(res.data.status=="OK"){
                return Promise.resolve(res.data.msg)
            }
            else{
                return Promise.reject(new Error(res.data.msg))
            }
        },(error) => {
            return Promise.reject(error)
        }).catch((error)=>{
            return Promise.reject(error)
        })
    }
}